import * as React from 'react';
import { NavigationContainer } from '@react-navigation/native';
import { createNativeStackNavigator } from '@react-navigation/native-stack';
import { createBottomTabNavigator } from '@react-navigation/bottom-tabs';
import { Text, View, TouchableOpacity } from 'react-native';
import Ionicons from 'react-native-vector-icons/Ionicons'; // 图标库

import HomeScreen from './Routes/HomeScreen';
import Buy from './Routes/Buy';
import SellScreen from './Routes/SellScreen';
import CartScreen from './Routes/CartScreen';
import My from './Routes/My';
import Daohang from './Routes/zjj/Daohang';
import PaymentScreen from './Routes/PaymentScreen';
// 创建Tab导航器
const Tab = createBottomTabNavigator();
const Stack = createNativeStackNavigator();

function TabNavigator() {



  return (
    <>
      <Tab.Navigator
        screenOptions={({ route }) => ({
          tabBarIcon: ({ focused, color, size }) => {
            let iconName;
            switch (route.name) {
              case '首页':
                iconName = focused ? 'home' : 'home';
                break;
              case '我要买':
                iconName = focused ? 'list' : 'list';
                break;
              case '我要卖':
                iconName = focused ? 'add-circle' : 'add-circle';
                break;
              case '购物车':
                iconName = focused ? 'cart' : 'cart';
                break;
              case '我的':
                iconName = focused ? 'person' : 'person';
                break;
            }

            return <Ionicons name={iconName} size={size} color={color} />;
          },
          tabBarActiveTintColor: '#ff0000',
          tabBarInactiveTintColor: '#999999',
          tabBarLabelStyle: {
            fontSize: 12,
            marginBottom: 5,
          },
          tabBarStyle: {
            height: 60,
            paddingTop: 5,
            backgroundColor: '#fff',
            borderTopWidth: 0, // 移除顶部边框
            elevation: 0, // Android移除阴影
          },
          headerShown: false,
        })}
      >
        <Tab.Screen
          name="首页"
          component={HomeScreen}
          options={{
            tabBarLabel: '首页'
          }}
        />
        <Tab.Screen
          name="我要买"
          component={Buy}
          options={{
            tabBarLabel: '我要买'
          }}
        />
        <Tab.Screen
          name="我要卖"
          component={SellScreen}
          options={{
            tabBarLabel: '我要卖'
          }}
        />
        <Tab.Screen
          name="购物车"
          component={CartScreen}
          options={{
            tabBarLabel: '购物车'
          }}
        />
        <Tab.Screen
          name="我的"
          component={My}
          options={{
            tabBarLabel: '我的'
          }}
        />
      </Tab.Navigator>

      <Stack.Screen name="Daohang" component={Daohang} />
      <Stack.Screen name="PaymentScreen" component={PaymentScreen} />

    </>
  );
}

export default TabNavigator;